class Solution {
public:
    vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
        unordered_set<int> mp, result;
        for (int i = 0; i < nums1.size(); i++) {
            mp.insert(nums1[i]);
        }
        for (int i = 0; i < nums2.size(); i++) {
            if (mp.find(nums2[i]) != mp.end()) {
                result.insert(nums2[i]);
            }
        }
        vector<int> vec(result.begin(), result.end());
        return vec;
    }
};
